<include file="public@header"/>

<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Classes/audition')}">试听列表</a></li>
    </ul>
    <form class="well form-inline margin-top-20 row" method="post" action="{:url('Classes/audition')}">
        <label class="form-group col-lg-5 col-md-6" style="margin-bottom:15px">
            校区-班级:
            <select class="form-control" name="school_id" id="school_id" style="width: 179px;">
                <option value='0'>全部</option>
                <notempty name="schools">
                    <volist name="schools" id="vo">
                        <if condition="isset($param.school_id) && $param.school_id == $vo.id">
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                        <else/>
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </volist>
                </notempty>
            </select>-
            <select class="form-control" name="class_id" id="class_id" style="width: 179px;">
                <option value='0'>全部</option>
                <notempty name="classes">
                    <volist name="classes" id="vo">
                        <if condition="isset($param.class_id) && $param.class_id == $vo.id">
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            <else/>
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </volist>
                </notempty>
            </select>
        </label>

        <label class="form-group col-lg-3 col-md-3" style="margin-bottom:15px">
            课程:
            <select class="form-control" name="course_id" id="course_id">
                <option value='0'>全部</option>
                <notempty name="course">
                    <volist name="course" id="vo">
                        <if condition="isset($param.course_id) && $param.course_id == $vo.id">
                            <option value="{$vo.id}" selected>{$vo.course_name}</option>
                            <else/>
                            <option value="{$vo.id}">{$vo.course_name}</option>
                        </if>
                    </volist>
                </notempty>
            </select>
        </label>

        <label class="form-group col-lg-4 col-md-3" style="margin-bottom:15px">
        </label>

        <label class="form-group col-lg-5 col-md-6">
            上课时间:&nbsp;&nbsp;
            <input type="text" class="form-control" name="start"
                   value="{$param.start|default=''}"
                   autocomplete="off">-
            <input type="text" class="form-control " name="end"
                   value="{$param.end|default=''}"
                   autocomplete="off">
        </label>

        <label class="form-group col-lg-3 col-md-3">
            状态:
            <select class="form-control" name="status" >
                <option value='-1'>全部</option>
                <if condition="isset($param.status) && $param.status == 0">
                    <option value="0" selected>未处理</option>
                <else/>
                    <option value="0">未处理</option>
                </if>
                <if condition="isset($param.status) && $param.status == 1">
                    <option value="1" selected>已插班</option>
                <else/>
                    <option value="1">已插班</option>
                </if>
                <if condition="isset($param.status) && $param.status == 2">
                    <option value="2" selected>已释放</option>
                <else/>
                    <option value="2">已释放</option>
                </if>
            </select>
        </label>

        <label class="form-group col-lg-4 col-md-3">
            <input type="submit" class="btn btn-primary" value="搜索"/>
            <a class="btn btn-danger" href="{:url('Classes/audition')}">清空</a>
        </label>
    </form>

    <form class="js-ajax-form" action="" method="post">
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th>编号</th>
                <th>学生</th>
                <th>联系方式</th>
                <th>校区</th>
                <th>班级</th>
                <th>课程</th>
                <th>课时</th>
                <th>价格(元)</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <notempty name="listen">
                <foreach name="listen" item="vo">
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.student_name}</td>
                        <td>{$vo.mobile}</td>
                        <td>{$vo.school_name}</td>
                        <td>{$vo.class_name}</td>
                        <td>{$vo.course_name}</td>
                        <td>{$vo.date|date="Y-m-d",###} {$vo.start_time}-{$vo.end_time}</td>
                        <td>{$vo.money}</td>
                        <if condition="$vo.status == 1">
                            <td><span class="label label-success">已插班</span></td>
                        <elseif condition="$vo.status == 2"/>
                            <td><span class="label label-danger">已释放</span></td>
                        <else/>
                            <td><span class="label label-warning">未处理</span></td>
                        </if>
                        <td>
                            <if condition="$vo.status == 0">
                                <a href="{:url('Classes/handle_audition',array('id'=>$vo.id, 'status'=>'y'))}" data-msg="确定要插班吗？" class="js-ajax-delete">插班</a> |
                                <a href="{:url('Classes/handle_audition',array('id'=>$vo.id, 'status'=>'n'))}" data-msg="确定要释放吗？" class="js-ajax-delete">释放</a>
                            </if>
                        </td>
                    </tr>
                </foreach>
            </notempty>
        </table>
        <div class="pagination">{$page|default=''}</div>
    </form>
</div>

<script src="__STATIC__/js/admin.js"></script>
<script>

    $(document).ready(function () {
        $('#school_id').on('change',function () {
            var sid = $(this).val();
            if(sid == 0){
                $('#class_id').empty();
                var html = '<option value=\"0\">全部</option>';
                $('#class_id').html(html);
                return false;
            }
            $.ajax({
                url:"{:url('Classes/ajax_class')}",
                type:'post',
                dataType:'json',
                data:{"school_id":sid},
                success:function(jsonData){
                    $('#class_id').empty();
                    var html = '<option value=\"0\">全部</option>';

                    if(jsonData.code == 1){
                        for(var i in jsonData.data){
                            html += '<option value=\"'+jsonData.data[i].id+'\">'+jsonData.data[i].name+'</option>';
                        }
                    }
                    $('#class_id').html(html);
                },
                error:function(XMLHttpRequest, textStatus, errorThrown){
                    console.log('xhr='+XMLHttpRequest.readyState+' status='+textStatus+' error='+errorThrown);
                }
            });
        });

        $('input[name="start"]').datepicker();
        $('input[name="end"]').datepicker();

    });

    function reloadPage(win) {
        win.location.reload();
    }

    function refersh_window() {
        var refersh_time = getCookie('refersh_time');
        if (refersh_time == 1) {
        }
    }
    setInterval(function () {
        refersh_window();
    }, 2000);
    $(function () {
        setCookie("refersh_time", 0);
        Wind.use('ajaxForm', 'artDialog', 'iframeTools', function () {
            //批量复制
            $('.js-articles-copy').click(function (e) {
                var ids = [];
                $("input[name='ids[]']").each(function () {
                    if ($(this).is(':checked')) {
                        ids.push($(this).val());
                    }
                });

                if (ids.length == 0) {
                    art.dialog.through({
                        id: 'error',
                        icon: 'error',
                        content: '您没有勾选信息，无法进行操作！',
                        cancelVal: '关闭',
                        cancel: true
                    });
                    return false;
                }

                ids = ids.join(',');
                art.dialog.open("__ROOT__/index.php?g=portal&m=AdminArticle&a=copy&ids=" + ids, {
                    title: "批量复制",
                    width: "300px"
                });
            });
            //批量移动
            $('.js-articles-move').click(function (e) {
                var ids = [];
                $("input[name='ids[]']").each(function () {
                    if ($(this).is(':checked')) {
                        ids.push($(this).val());
                    }
                });

                if (ids.length == 0) {
                    art.dialog.through({
                        id: 'error',
                        icon: 'error',
                        content: '您没有勾选信息，无法进行操作！',
                        cancelVal: '关闭',
                        cancel: true
                    });
                    return false;
                }

                ids = ids.join(',');
                art.dialog.open("__ROOT__/index.php?g=portal&m=AdminArticle&a=move&old_term_id={$term.term_id|default=0}&ids=" + ids, {
                    title: "批量移动",
                    width: "300px"
                });
            });
        });
    });
</script>
</body>